home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
ab20
/
ab20_archive
/
datacomm
/
ncomm921.lzh
/
PbView.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-08-08
|
3KB
|
113 lines
/* PbView for use with NComm V1.9 or later */
/* Displays an NComm phonebook file in a */
/* very ugly and badly formatted way :-) */
/* Public Domain by Torkel Lodberg 1991 */
#include <stdio.h>
#include <exec/types.h>
#include <exec/memory.h>
#include <intuition/intuition.h>
#include <proto/intuition.h>
#include <proto/graphics.h>
#include <proto/exec.h>
#include <fcntl.h>
#include <ctype.h>
#include <math.h>
#define NEW_FILETYPE_PHONE 6
static struct pb_Data { /*** V1.92-> file format ***/
UBYTE name[41];
UBYTE phone[61];
UBYTE comment[41];
UBYTE pass_word[30];
UBYTE script_file[33];
UBYTE config_file[33];
UBYTE macro_file[33];
UBYTE char_set; /*** 0-12 ***/
UBYTE baud; /*** 0-11 (300 - 115200) ***/
UBYTE data_length; /*** 7 or 8 ***/
UBYTE parity; /*** None, odd, even ***/
UBYTE stop_bits; /*** 1 - 2 ***/
UBYTE duplex; /*** Full - half ***/
UBYTE swap_del_bs; /*** Swap Del/BS ***/
UBYTE protocol; /*** Protocol (0-6) ***/
UBYTE future[62];
};
static int fd = NULL; /* File handle */
UBYTE wb_open; /* Started from workbench? */
void
cleanup(text) /* Exit program cleanly */
char *text;
{
if (text)
printf("%s\n", text);
if (fd > 0)
close(fd);
if (wb_open)
Delay(100);
exit(0);
}
void
brk()
{ /* Called by every CTRL-C / D keypress */
printf("*** BREAK\n");
cleanup(NULL);
}
void
main(argc, argv) /* Main program */
int argc;
char *argv[];
{
char ch, answer[256], infile[256];
struct pb_Data data;
if (!argc)
wb_open = TRUE;
else
wb_open = FALSE;
if (onbreak(&brk))
cleanup(NULL);
chkabort();
if (wb_open || argc > 2) {
printf("PbView for use with NComm V1.9 or later.\n"
"Public Domain by Torkel Lodberg 1991\n\n");
if (!wb_open) {
printf(" Usage: PbConvert [phonebook]\n\n");
cleanup(NULL);
}
}
if (argc < 2)
strcpy(infile, "NComm:NComm.phone");
else
strcpy(infile, argv[1]);
if (wb_open) {
printf("Enter name of phonebook file (Enter=NComm:NComm.phone): ");
gets(answer);
if (strlen(answer))
strcpy(infile, answer);
printf("\n");
}
if ((fd = open(infile, O_RDONLY, NULL)) == -1 || read(fd, &ch, 1) != 1)
cleanup("Cannot open data-file");
if (ch != NEW_FILETYPE_PHONE)
cleanup("Error reading NComm.phone: Illegal file type");
while ((read(fd, (char *) &data, sizeof(struct pb_Data))) == sizeof(struct pb_Data)) {
printf("%-30s %s\n", data.name, data.phone);
}
cleanup(NULL);
}